package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelLabelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmSensitive;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 频道标签信息表 前端控制器
 * </p>
 *
 * @author 李海鹏
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class AdChannelLabelController {

    @Autowired
    private AdChannelLabelService  adChannelLabelService;

    /**
     * 新增一个频道
     *
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel){
        log.info("进入到了admin");
        return adChannelLabelService.saveChannel(wmChannel);
    }

    /**
     * 频道的分页查询
     *
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto){
        log.info("controller接受到的数据为——————{}",dto.getPage() +" "+dto.getSize());
        return adChannelLabelService.listChannel(dto);
    }

    /**
     *对channel表的修改
     *
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel dto) {
        return adChannelLabelService.updateChannel(dto);

    }

    /**
     * 对频道的删除
     *
     * @param
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable("id") Integer id) {

        log.info("controller 收到的id为{}",id);


        return adChannelLabelService.delChannel(id);
    }

}
